package com.zly.framework.rbac.model.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.zly.framework.rbac.vaildate.EntityInsert;
import com.zly.framework.rbac.vaildate.EntityUpdate;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Table;
import jakarta.persistence.Transient;
import jakarta.validation.constraints.Pattern;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;

import java.util.List;


@Data
@Entity
@EqualsAndHashCode(callSuper = true)
@Table(name = "sys_role")
@TableName("sys_role")
@ToString(callSuper = true)
public class Role extends BaseEntity {
    @Schema(description = "角色名")
    @Column(name = "name")
    @Pattern(regexp = "^ROLE_.*$", message = "角色必须以ROLE_开头", groups = {EntityInsert.class, EntityUpdate.class})
    private String name;

    @Schema(description = "角色描述")
    @Column(name = "description")
    private String description;

    @Transient
    @TableField(exist = false)
    @Schema(description = "角色拥有菜单列表")
    private List<Permission> permissions;

}
